package com.hurl.waguji.web.cx;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.hurl.library.util.DateUtils;
import com.hurl.waguji.base.SqlReader;
import com.hurl.waguji.base.dao.HibernateDao;
import com.hurl.waguji.base.dao.HibernateService;
import com.opensymphony.xwork2.ActionSupport;

public class ListAction extends ActionSupport{
	private Map<String,Object> queryResults = new HashMap<String,Object>();
	
	public Map<String,Object> getQueryResults(){
		return this.queryResults;
	}
	
	public String execute()throws Exception{
		return SUCCESS;
	}
	private String formatDate(Date d){
		return DateUtils.formatDate(d, DateUtils.FORMAT_DATE);
	}
	public String query()throws Exception{
		HibernateDao dao = HibernateService.getDao();
		
		List<Object[]> list = dao.queryBySQL(SqlReader.getSql("SQL12042801")).setReadOnly(true).list();
		Map<String,Object> rowmap = null;
		List<Map<String,Object>> root = new ArrayList<Map<String,Object>>();
		for(Object[] row : list){
			rowmap = new HashMap<String,Object>();
			rowmap.put("gpdm", row[0]);
			rowmap.put("gpmc", row[1]);
			rowmap.put("gplx_mc", row[2]);
			rowmap.put("gs_sshy_mc", row[3]);
			rowmap.put("gs_qy_mc", row[4]);
			rowmap.put("gs_ssrq", row[5]);
			rowmap.put("gs_fxjg", row[6]);
			root.add(rowmap);
		}
		queryResults.put("totalProperty", root.size());
		queryResults.put("root", root);
		
		return SUCCESS;
	}
}
